package com.zls.controller;

import com.zls.pojo.User;
import com.zls.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/user")
public class ThymeleafController {
    @Autowired
    private UserService userService;
    @RequestMapping("/index")
    public String demo01(Model model){
        System.out.println("controller执行了");
        model.addAttribute("msg","hello-thymeleaf");
        return "demo";
    }
    @RequestMapping("/list")
    public String demo02(Model model){
        List<User> list = userService.list();
        model.addAttribute("user",list);
        return "demo";
    }
}
